/*
 * @Author: zingpp
 * @Date: 2025-06-19 17:44:45
 * @LastEditors: zingpp
 * @LastEditTime: 2025-06-19 17:54:07
 * @FilePath: \cool-server\src\app.module.ts
 * @Description:
 *
 * Copyright (c) 2025 by 用户/公司名, All Rights Reserved.
 */
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { EventEmitterModule } from '@nestjs/event-emitter';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserModule } from './modules/user/user.module';
import { AuthModule } from './modules/auth/auth.module';
import { ProductModule } from './modules/product/product.module';
import { OrderModule } from './modules/order/order.module';
import { CartModule } from './modules/cart/cart.module';
import { PaymentModule } from './modules/payment/payment.module';
import { AdminModule } from './modules/admin/admin.module';
import { MarketingModule } from './modules/marketing/marketing.module';
import databaseConfig from './config/database.config';
import { CacheModule } from '@nestjs/cache-manager';
import { cacheConfig } from './config/cache.config';
import { BullModule } from '@nestjs/bull';
import { bullConfig } from './config/bull.config';
import { ScheduleModule } from '@nestjs/schedule';
import { CustomerServiceModule } from './modules/customer-service/customer-service.module';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      load: [databaseConfig],
    }),
    TypeOrmModule.forRootAsync({
      imports: [ConfigModule],
      useFactory: (configService: ConfigService) => {
        const dbConfig = configService.get('database');
        return dbConfig;
      },
      inject: [ConfigService],
    }),
    CacheModule.register(cacheConfig),
    BullModule.forRoot(bullConfig),
    ScheduleModule.forRoot(),
    EventEmitterModule.forRoot(),
    UserModule,
    AuthModule,
    ProductModule,
    OrderModule,
    CartModule,
    PaymentModule,
    AdminModule,
    MarketingModule,
    CustomerServiceModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
